package com.gitee.W_Jun;

import java.util.Date;

/**
 * @author https://gitee.com/W_Jun
 * @date 2021-12-23 21:28
 * @Description 局部变量表所需容量大小是编译期确定下来的。
 *
 * 反编译后查看main方法的局部变量表，如下：
 *  LocalVariableTable:
 *         Start  Length  Slot  Name   Signature
 *             0      16     0  args   [Ljava/lang/String;
 *             8       8     1  test   Lcom/gitee/W_Jun/LocalVariablesTest;
 *            11       5     2   num   I
*  还可以查看到main方法的局部变量表的容量：
 *  Code:
 *       stack=2, locals=3, args_size=1
 */
public class LocalVariablesTest {
    private int count = 0;

    public static void main(String[] args) {
        LocalVariablesTest test = new LocalVariablesTest();
        int num = 10;
        test.test1();
    }

    public void test1() {
        Date date = new Date();
        String name1 = "java";
        String info = test2(date, name1);
        System.out.println(date + name1);
    }

    public String test2(Date dateP, String name2) {
        dateP = null;
        name2 = "zhangsan";
        double weight = 130.5;
        char gender = '男';
        return dateP + name2;
    }

    public void test3() {
        count++;
    }

    public void test4() {
        int a = 0;
        {
            int b = 0;
            b = a + 1;
        }
        int c = a + 1;
    }

}
